home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
oath.lha
/
oath
/
test
/
stable.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-29
|
3KB
|
88 lines
#include "oath/oath.h"
#include "timer.h"
#include <iostream.h>
//***************************************************************************
#define COUNT 1000000
const int& foo (const int& I) {return I;}
const objA& foo (const objA& O) {return O;}
main()
{stringTableA ST7 = stringTableA::make(7);
stringTableA ST11 = stringTableA::make(11);
cout << "sizeof(stringTableA) = " << sizeof(stringTableA) << endl;
cout << "sizeof(stringTableG) = " << sizeof(stringTableG) << endl;
cout << "sizeof(stNodeP) = " << sizeof(stNodeP) << endl;
stringTokenA Declaration = stringTokenA::make("Declaration");
stringTokenA Definition = stringTokenA::make("Definition");
stringTokenA Initializer = stringTokenA::make("Initializer");
cout << endl;
cout << Declaration.string() << " hash(" << Declaration.hash() << ")"
<< " mod7(" << Declaration.hash() % 7 << ")"
<< " mod11(" << Declaration.hash() % 11 << ")"
<< endl;
cout << Definition.string() << " hash( " << Definition.hash() << ")"
<< " mod7(" << Definition.hash() % 7 << ")"
<< " mod11(" << Definition.hash() % 11 << ")"
<< endl;
cout << Initializer.string() << " hash(" << Initializer.hash() << ")"
<< " mod7(" << Initializer.hash() % 7 << ")"
<< " mod11(" << Initializer.hash() % 11 << ")"
<< endl;
tokenA DeclValue = localTokenA::make();
tokenA DefnValue = localTokenA::make();
tokenA InitValue = localTokenA::make();
ST7.insert(Declaration, DeclValue);
ST7.insert(Definition, DefnValue);
ST7.insert(Initializer, InitValue);
ST11.insert(Declaration, DeclValue);
ST11.insert(Definition, DefnValue);
ST11.insert(Initializer, InitValue);
cout << endl;
objA Value;
int I, J;
timer Timer;
Timer.start();
for(I = 0; I < COUNT; ++I)
J = foo(I);
Timer.split();
cout << COUNT << " retrievals from int I ------ " << Timer.cpu() << " ms"
<< endl;
Timer.start();
for(I = 0; I < COUNT; ++I)
Value = foo(DeclValue);
Timer.split();
cout << COUNT << " retrievals from DeclValue -- " << Timer.cpu() << " ms"
<< endl;
Timer.start();
for(I = 0; I < COUNT; ++I)
Value = foo(ST7.assoc(Declaration));
Timer.split();
cout << COUNT << " retrievals from ST7 -------- " << Timer.cpu() << " ms"
<< endl;
Timer.start();
for(I = 0; I < COUNT; ++I)
Value = foo(ST11.assoc(Declaration));
Timer.split();
cout << COUNT << " retrievals from ST11 ------- " << Timer.cpu() << " ms"
<< endl;
}